#include<iostream>
#include<unistd.h>
#include<signal.h>

void handler(int signum)
{
    std::cout<<"我是"<<signum<<"号信号!"<<std::endl;
}

int main()
{
    signal(2, handler);
    while(1)
    {
        std::cout<< "I am a signal! My pid is:"<<getpid()<<std::endl;
        sleep(1);
    }
    return 0;
}